Skip to content

Plan 89: TOC generator directive and MDS035 auto-fix - #147

Merged
jeduden merged 1 commit into
mainfrom
claude/plan-89-toc-generator-directive
Apr 19, 2026
Merged

Plan 89: TOC generator directive and MDS035 auto-fix#147
jeduden merged 1 commit into
mainfrom
claude/plan-89-toc-generator-directive

Conversation

@jeduden

@jeduden jeduden commented Apr 19, 2026

Copy link
Copy Markdown
Owner

Summary

This PR adds plan 89 to the mdsmith roadmap, which outlines the implementation of a native <?toc?> directive for generating table of contents from document headings, along with upgrading MDS035 to auto-fix renderer-specific TOC tokens by converting them to the new directive.

Changes

  • Added plan/89_toc-generator-directive.md: Comprehensive design document for the TOC generator feature including:

    • Directive syntax with min-level and max-level parameters
    • Generated content specification (nested unordered lists with GitHub-style heading slugs)
    • MDS036 rule definition (new rule for validating TOC directive bodies)
    • MDS035 auto-fix strategy (converting [TOC], [[_TOC_]], [[toc]], ${toc} to <?toc?> blocks)
    • Interaction with existing rules (MDS015, MDS020, MDS019, MDS021)
    • Detailed task breakdown and acceptance criteria
  • Updated PLAN.md: Added plan 89 entry to the roadmap table

Implementation Details

The plan leverages mdsmith's existing generated-section machinery (used by <?catalog?> and <?include?>) to implement the TOC directive. Key design decisions:

  • Multi-pass fix strategy: MDS035 emits empty <?toc?> blocks, then MDS036 populates them in a subsequent pass
  • GitHub-flavor slug generation for heading anchors with disambiguation for duplicates
  • Respects document heading structure (not raw level numbers) for nested list generation
  • Default min-level: 2 excludes document title, matching Python-Markdown behavior
  • Comprehensive test coverage including fixtures for good/bad/fixed states and integration tests

https://claude.ai/code/session_01T569bC9ogHHf5A6Cgxn9NW

Follow-up to plan 88. Adds a <?toc?>...<?/toc?> generated-section
directive (MDS036) that emits a nested list of the document's
headings, and upgrades MDS035 from detection-only to auto-fix by
rewriting the four detected renderer-specific TOC tokens into
<?toc?> blocks that MDS036 then populates on the next fix pass.

Design notes:

- New rule MDS036 "toc" (meta, default-enabled, fixable) built on
  the shared internal/archetype/gensection engine that MDS019
  catalog already uses.
- Parameters: min-level (default 2, matches Python-Markdown [TOC])
  and max-level (default 6). Output is GitHub-slug links.
- MDS035 Fix leaves [TOC] untouched when a matching link reference
  definition makes it resolve to a real link.
- Relies on mdsmith's existing multi-pass fix; falls back to
  emitting populated content directly from MDS035 only if that
  proves brittle.
Copilot AI review requested due to automatic review settings April 19, 2026 20:47
@jeduden jeduden added the queue Add to a PR to enqueue it label Apr 19, 2026
@codecov

codecov Bot commented Apr 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.35%. Comparing base (ccd272a) to head (d65713a).
⚠️ Report is 12 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #147   +/-   ##
=======================================
  Coverage   86.35%   86.35%           
=======================================
  Files          94       94           
  Lines       10149    10149           
=======================================
  Hits         8764     8764           
  Misses        903      903           
  Partials      482      482           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds roadmap plan 89 describing a native <?toc?> generated-section directive and an accompanying MDS035 auto-fix that migrates renderer-specific TOC tokens to <?toc?> blocks.

Changes:

  • Added plan 89 design/spec document for <?toc?> (MDS036) and MDS035 auto-fix/multi-pass behavior.
  • Updated PLAN.md catalog output to include the new plan entry.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
plan/89_toc-generator-directive.md New plan detailing directive syntax, slugging rules, MDS036 rule behavior, and MDS035 fix strategy.
PLAN.md Adds plan 89 to the generated roadmap table.

Comment thread plan/89_toc-generator-directive.md
Comment thread plan/89_toc-generator-directive.md
Comment thread plan/89_toc-generator-directive.md
Comment thread plan/89_toc-generator-directive.md
Comment thread plan/89_toc-generator-directive.md
Comment thread plan/89_toc-generator-directive.md
@jeduden jeduden added queue:active Applied automatically when a PR is in an active batch and removed queue Add to a PR to enqueue it labels Apr 19, 2026
@jeduden

jeduden commented Apr 19, 2026

Copy link
Copy Markdown
Owner Author

🟢 Merge Queue — picked up

This PR is in the queue and will be batched with other queue-labelled PRs.

Next: No action needed — you'll get another comment when CI starts on the batch. View merge queue run.

@jeduden

jeduden commented Apr 19, 2026

Copy link
Copy Markdown
Owner Author

🔵 Merge Queue — CI running

Merged into batch branch merge-queue/batch-143-1776631862 alongside #143. View CI run.

Next: No action needed — you'll be notified when CI completes.

@jeduden
jeduden merged commit fef3ac3 into main Apr 19, 2026
15 checks passed
@jeduden

jeduden commented Apr 19, 2026

Copy link
Copy Markdown
Owner Author

Merge Queue — merged

This PR landed on main via commit fef3ac3. CI run that validated the merge.

Next: Done — nothing more to do here.

@jeduden jeduden removed the queue:active Applied automatically when a PR is in an active batch label Apr 19, 2026
jeduden pushed a commit that referenced this pull request Apr 19, 2026
- Renumber MDS036 → MDS037 for the toc rule. Plan 51 shipped first
  and took MDS036 for max-section-length; MDS034 stays reserved for
  plan 86.
- Replace the hand-rolled slug algorithm with a directive to move
  the existing slugify / duplicate-disambiguation logic out of
  crossfilereferenceintegrity into a shared helper
  (internal/mdtext) that both rules call. Drops incorrect
  goldmark-meta reference.
- Drop fictitious <?listindent?> directive reference; describe
  indentation as MDS016 list-indent.spaces (default 2).
- Correct MDS015 interaction note: MDS015 only covers fenced code
  blocks, so blank-line padding around <?toc?> is MDS035 Fix's
  responsibility.
- Unify the canonical empty-body form as <?toc?>\n<?/toc?>
  throughout design, tasks, and acceptance criteria.
- Add task 1 (move slug helper to shared package) and renumber
  downstream tasks.
- Grammar pass: "GitHub-style" consistently.

Follow-up to PR #147 (already merged).
@jeduden

jeduden commented Apr 19, 2026

Copy link
Copy Markdown
Owner Author

Addressed all six Copilot review threads in follow-up PR #148. Summary of fixes:

  • Renumber MDS036 → MDS037 (MDS036 shipped on plan 51 as max-section-length)
  • Reuse existing slugify from crossfilereferenceintegrity via a shared internal/mdtext helper; drops the goldmark-meta reference
  • Drop the fictitious <?listindent?> directive; reference MDS016 list-indent.spaces instead
  • Correct MDS015 claim (MDS015 only covers fenced code blocks)
  • Unify empty-body form as <?toc?>\n<?/toc?> throughout
  • Grammar: "GitHub-style"

jeduden pushed a commit that referenced this pull request Apr 20, 2026
- Renumber MDS036 → MDS037 for the toc rule. Plan 51 shipped first
  and took MDS036 for max-section-length; MDS034 stays reserved for
  plan 86.
- Replace the hand-rolled slug algorithm with a directive to move
  the existing slugify / duplicate-disambiguation logic out of
  crossfilereferenceintegrity into a shared helper
  (internal/mdtext) that both rules call. Drops incorrect
  goldmark-meta reference.
- Drop fictitious <?listindent?> directive reference; describe
  indentation as MDS016 list-indent.spaces (default 2).
- Correct MDS015 interaction note: MDS015 only covers fenced code
  blocks, so blank-line padding around <?toc?> is MDS035 Fix's
  responsibility.
- Unify the canonical empty-body form as <?toc?>\n<?/toc?>
  throughout design, tasks, and acceptance criteria.
- Add task 1 (move slug helper to shared package) and renumber
  downstream tasks.
- Grammar pass: "GitHub-style" consistently.

Follow-up to PR #147 (already merged).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants